package net.qhzw.geologr5.gis.service.system.controller;

import net.qhzw.geologr5.gis.common.framework.utils.JsonResult;
import net.qhzw.geologr5.gis.service.system.entity.Software;
import net.qhzw.geologr5.gis.service.system.entity.Standard;
import net.qhzw.geologr5.gis.service.system.query.SoftwareQuery;
import net.qhzw.geologr5.gis.service.system.query.StandardQuery;
import net.qhzw.geologr5.gis.service.system.service.SoftwareService;
import net.qhzw.geologr5.gis.service.system.service.StandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/***
 * 下载管理前端
 */

@RestController
@RequestMapping("download")
public class DownloadController {


    @Autowired
    private StandardService standardService;


    /**
     * 软件表service
     */
    @Autowired
    private SoftwareService softwareService;

    /***
     * 查询规范列表
     * @return
     */
    @GetMapping("findStandard")
    public JsonResult findStandard(StandardQuery query) {
        return standardService.findStandard(query);
    }

    /***
     * 创建规范列表
     * @param standard
     * @return
     */
    @PostMapping("createStandard")
    public JsonResult createStandard(@RequestBody Standard standard) {
        return standardService.createStandard(standard);
    }


    /***
     * 删除规范表
     * @param ids
     * @return
     */
    @DeleteMapping("deleteStandard/{ids}")
    public JsonResult deleteStandard(@PathVariable("ids") Integer[] ids) {
        return standardService.deleteByIds(ids);
    }


    /***
     * 规范上传
     * @return
     */
    @PostMapping("uploadStandard")
    public JsonResult uploadStandard(Standard standard, @RequestParam MultipartFile file) {
        if (standard == null){
            return JsonResult.error("参数为空");
        }
        return standardService.uploadStandard(standard, file);
    }

    /***
     * 软件列表查询
     * @return
     */
    @GetMapping("findSoftware")
    public JsonResult findSoftware(SoftwareQuery query) {
        return softwareService.findSoftware(query);
    }


    /***
     * 新增|修改软件表
     * @return
     */
    @PostMapping("editorSoftware")
    public JsonResult editorSoftware(@RequestBody Software software) {
        return softwareService.editorSoftware(software);
    }


    /***
     * 删除软件表
     * @param ids
     * @return
     */
    @DeleteMapping("deleteSoftware/{ids}")
    public JsonResult deleteSoftware(@PathVariable("ids") Integer[] ids) {
        return softwareService.deleteSoftware(ids);
    }

    /***
     * 软件上传
     * @return
     */
    @PostMapping("softwareUpload")
    public JsonResult softwareUpload(Software software, @RequestParam MultipartFile file) {
        return softwareService.upload(software, file);
    }


    /***
     * 查询类别
     * @return
     */
    @GetMapping("getSpecialty")
    public JsonResult getSpecialty() {
        return standardService.getSpecialty();
    }

}
